/*
 * Plugin.cpp
 *
 *  Created on: 2011. 3. 15.
 *      Author: JeeHoon
 */
#include "api/Plugin.h"

using namespace Osp::Base;


Plugin::Plugin()
{
	__callBackQueue.Construct();
}

Plugin::~Plugin()
{
	__callBackQueue.RemoveAll();
}

result
Plugin::enqueueParameter(Osp::Base::String callBackID,Osp::Base::String args)
{
	result r = E_SUCCESS;
	if(E_SUCCESS == r) r = __callBackQueue.Enqueue(callBackID);
	if(E_SUCCESS == r) r = __callBackQueue.Enqueue(args);
	return r;
}

result
Plugin::dequeueParameter(Osp::Base::String &callBackID,Osp::Base::String &args)
{
	result r = E_SUCCESS;
	if(E_SUCCESS == r) r = __callBackQueue.Dequeue(callBackID);
	if(E_SUCCESS == r) r = __callBackQueue.Dequeue(args);
	return r;
}

result
Plugin::Construct(PluginManager * pPluginManager, Osp::Base::String pluginName)
{
	result r = E_SUCCESS;

	if(E_SUCCESS == r)
	{
		if(NULL != pPluginManager)
			__pPluginManager = pPluginManager;
		else
		{
			printLog(L"pPluginManager is NULL");
			r = E_INVALID_ARG;
		}
	}

	if(E_SUCCESS == r)
	{
		r = OnConstruct(pPluginManager,pluginName);
		if(E_SUCCESS != r)
		{
			printLog(L"on Construct()," + pluginName + " is OnConstruct is not success.");
		}
	}

	return r;
}
